package src.greedy_algorithms;

/**
 * @author starsea
 * @date 2024-08-27 8:47
 */

public class Test03 {
    public static void main(String[] args) {
        String s="III";
        int [] arr=diStringMatch(s);

    }
    public static int[] diStringMatch(String s) {
        int n=s.length();
        int [] arr=new int[n+1];
        int i=0;
        int j=0;
        for(char ch: s.toCharArray())
        {
            if(ch=='I')
            {
                arr[j]=i;
                i++;
            }
            else
            {
                arr[j]=n;
                n--;
            }
            j++;
        }
        arr[j]=i;
        return arr;
    }
}
